<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/home/special.css" />
	</head>

	<body>
		<div id="special">
			<header class="mui-bar mui-bar-nav">
				<div class="seach_input"><span><input type="text" placeholder="请输入关键字" readonly="true"/></span></div>
				<div class="publish">
					<div class="publish_img"><img src="../../images/fabiao.png" /></div>
					<div>发布</div>
				</div>
			</header>

		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/libs/zepto.js"></script>
		<script src="../../js/common.js"></script>
		<script type="text/javascript">
			mui.init({
				subpages: [{
					url: '../special/specialregion.html', //子页面HTML地址，支持本地地址和网络地址
					id: '../special/specialregion.html', //子页面标志
					styles: {
						top: '44px', //子页面顶部位置
						bottom: 0, //子页面底部位置
					},
					extras: {} //额外扩展参数
				}]
			});
			mui.plusReady(function() {
				$('.seach_input input').on("tap", function() {
					var wp = plus.webview.create('../seach/seach.html', '../seach/seach.html', {
						scrollIndicator: 'none',
						scalable: false,
						popGesture: 'none'
					}, {
						preate: true
					})
					wp.show('fade-in');
				})

				$('.publish').on('tap', function() {
					if(!JSON.parse(localStorage.getItem('userData'))){
						plus.webview.open('../login/login.html', '../login/login.html', {}, 'slide-in-right')
						return
					}
					if(mui.os.plus) {
						var a = [{
							title: "拍照"
						}, {
							title: "从手机相册选择"
						}];
						plus.nativeUI.actionSheet({
							title: "发布专题",
							cancel: "取消",
							buttons: a
						}, function(b) {
							switch(b.index) {
								case 0:
									break;
								case 1:
									getImage();
									break;
								case 2:
									galleryImg();
									break;
								default:
									break
							}
						})
					}
				})

				function getImage() {
					var c = plus.camera.getCamera();

					c.captureImage(function(e) {
						plus.io.resolveLocalFileSystemURL(e, function(entry) {
							var s =[entry.toLocalURL() + "?version=" + new Date().getTime()];
							common.open('../special/special_publish.html', '../special/special_publish.html',s)
						}, function(e) {
							console.log("读取拍照文件错误：" + e.message);
						});
					}, function(s) {
						console.log(JSON.stringify(s))
						mui.toast('请检查该app相机授权')
					}, {
						filename: "_doc/head.jpg"
					})
				}

				function galleryImg() {
					// 从相册中选择图片
					plus.gallery.pick(function(e) {
						common.open('../special/special_publish.html', '../special/special_publish.html', e.files)
					}, function(e) {
						common.toast('取消选择图片');
					}, {
						filter: 'image',
						multiple: true,
						maximum: 9,
						system: false,
						onmaxed: function() {
							plus.nativeUI.alert('最多只能选择9张图片');
						}
					}); // 最多选择9张图片
				};
			})
		</script>
	</body>

</html>